<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改规格')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-spec-edit" th:object="${spec}">
			<input id="specId" name="specId" type="hidden" th:field="*{specId}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label">规格名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="specName" id="specName" th:field="*{specName}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">规格备注：</label>
				<div class="col-sm-8">
					<textarea id="specSize" name="specSize" class="form-control">[[*{specSize}]]</textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "product/spec";
		
		$("#form-spec-edit").validate({
			onkeyup: false,
			rules:{
				specName:{
					remote: {
		                url: ctx + "product/spec/checkSpecNameUnique",
		                type: "post",
		                dataType: "json",
						data: {
							"specName" : function() {
								return $.common.trim($("#specName").val());
							}
						},
						dataFilter: function(data, type) {
							return $.validate.unique(data);
						}
		            }
				},
			},
			messages: {
				"specName": {
					remote: "规格名称已经存在"
				},
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-spec-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
